/*
 * FireballSprite.java
 *
 * Created on January 19, 2008, 11:19 PM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package wisp.game;
//JFC
import com.golden.gamedev.object.sprite.AdvanceSprite;
import java.awt.Graphics2D;
import java.awt.Dimension;
import java.awt.*;
import java.awt.event.*;
import java.awt.image.*;
import java.net.*;



// GTGE
import com.golden.gamedev.*;
import com.golden.gamedev.object.*;
import com.golden.gamedev.engine.BaseLoader;
/**
 *
 * @author Solomon See
 */
public class FireballSprite extends ParticleSprite {
    protected double range, speed;
    /** Creates a new instance of FireballSprite */
    public FireballSprite(BufferedImage[] images, double x, double y, double speed, int direction, double range) {
        super(images, x, y, 0.5, 0);
        initX = x - (getWidth() /2);
        initY = y - (getHeight() /2);
        this.setLocation(initX, initY);
        this.speed = speed;
        setDirection(direction);        
        this.range = range;
    }
    public void update(long elapsedTime) {
        if (Math.abs(getX() - initX) >= range)            
            setActive(false);             
        if (Math.abs(getY() - initY) >= range)            
            setActive(false);         
        super.update(elapsedTime);
    }        

    public void setDirection(int dir) {
        super.setDirection(dir);
        switch(getDirection()) {
        /*DOWN*/	case 1: setSpeed(0.0, speed); break;
        /*LEFT*/	case 2: setSpeed(-speed, 0.0); break;
        /*RIGHT*/	case 3: setSpeed(speed, 0.0); break;
        /*UP*/		case 4: setSpeed(0.0, -speed); break;
        }
    }
}
